package com.tiger.weightcheck;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class ResultActivity extends BaseActivity {
	PreferenceDataUtil util=new PreferenceDataUtil(this);
	private Button recheck;
	private TextView title,desc;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.result);
        CommonUtil.setAdView(this, this);
        recheck=(Button)this.findViewById(R.id.recheck);
        title=(TextView)this.findViewById(R.id.resultTitle);
        desc=(TextView)this.findViewById(R.id.resultDesc);
        String checkResult=util.ReadSharedPreferences(util.CHECKRESULT, "-1");
		if(checkResult.equals("-1")){
			title.setText("未进行测试无测试结果");
			desc.setText("未进行测试无测试结果");
		}else{
			float resultFloat=Float.parseFloat(checkResult);
			if(resultFloat<=5.0){
				title.setText(R.string.answer_title_1);
				desc.setText(R.string.answer_1);
			}else if(resultFloat>5.0&&resultFloat<=10.0){
				title.setText(R.string.answer_title_2);
				desc.setText(R.string.answer_2);
			}else{
				title.setText(R.string.answer_title_3);
				desc.setText(R.string.answer_3);
			}
		}
        recheck.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				ResultActivity.this.startActivity(new Intent(ResultActivity.this,MainActivity.class));
			}
        	
        });
    }
}